﻿@using IterationLife.FootballTeaching.Queries
@using Util.Ui
@model IterationLife.PlatformBackEnd.AppServices.Dtos.FootballTeachings.PlayerPositionDto
@{
    var x = @Html.EasyUi();
}
<script type="text/javascript">
    var dialog_playerPosition_Choice = function () {
        var checkedRows = $.easyui.getGrid("grid_dialog_playerPosition").datagrid("getChecked");
        if (checkedRows.length === 0) {
            $.easyui.warn("最少选择一个球员位置");
            return;
        }
        var show = '';

        var getExcludeIds = function () {
            var onclick = $("#dialogButtonsBtn_playerPosition").attr("onclick");
            var excludeIdsStr = onclick.match(/excludeIds=(\S*)'/)[1];
            if (!excludeIdsStr)
                return [];
            return excludeIdsStr.split(',');
        }
        var excludeIds = getExcludeIds();

        for (var i = 0; i < checkedRows.length; i++) {
            var playerPosition_option_gethtml = function (number, playerPosition) {
                var li = '<div onclick="delete_playerPosition(this,\'' + playerPosition.Id + '\')">';
                li += '<input type="text" name="PlayerPositions[' + number + '].Id" value="' + playerPosition.Id + '" hidden/>';
                li += '<input type="text" name="PlayerPositions[' + number + '].Name" value="' + playerPosition.Name + '" hidden/>';
                li += '<span class="course-option">' + playerPosition.Name + '</span>';
                li += '</div>';
                return li;
            }
            show += playerPosition_option_gethtml(excludeIds.length, checkedRows[i]);
            excludeIds.push(checkedRows[i].Id);
        }
        $("#dialogButtonsBtn_playerPosition").attr("onclick", "$.easyui.dialog({ title: '选择位置', buttons: 'dialogButtons_playerPosition', url: '/FootballTeachings/playerPosition/DialogIndex?excludeIds=" + excludeIds + "' })");
        $("#dd_playerPositions_data").append(show);
        $.easyui.closeDialog();
    }
</script>
@using (x.Layout(true).Begin())
{
    using (x.LayoutRegion().Center().Begin())
    {
        @Html.Partial("Dialogs/QueryForm", new PlayerPositionQuery { ExcludeIds = Model.ExcludeIds,Enabled = true})
        @(x.Grid("grid_dialog_playerPosition").Sort("SortId", false).Toolbar("divQuery_dialog_playerPosition").Url($"/FootballTeachings/PlayerPosition/PagerQuery?ExcludeIds={Model.ExcludeIds}")
        .ShowEditDialogByDblClick().Menu().FitColumns().Fit()
        .Columns(
            x.GridColumn(t => t.Id).CheckBox(),
            x.GridColumn(t => t.Code, 100),
            x.GridColumn(t => t.Name, 100),
            x.GridColumn(t => t.SortId, 100),
            x.GridColumn(t => t.CreationTime, 120)
        ).Pagination(true, 10)
        )
    }
}
<div id="dialogButtons_playerPosition">
    @x.Button("保 存").Icon("icon-ok").Width(90).Click("dialog_playerPosition_Choice()")
    @x.DialogButton("关 闭").Icon("icon-cancel").Width(90).CloseDialog()
</div>